package imvu.rbox.global
{
	import anshe.error.CreateError;
	import anshe.object.MessageBox;
	
	import flash.display.DisplayObjectContainer;
	import flash.events.Event;
	
	import imvu.rbox.struct.CGamePlayerInfo;
	import imvu.rbox.struct.CGameRoomInfo;
	
	public class GStatic extends Object
	{
		public static var isFreeVer:Boolean			= false;		//	是否为免费版本
		
		public static var myInfo:CGamePlayerInfo 	= new CGamePlayerInfo();	//	当前用户信息
		public static var nowRoom:CGameRoomInfo		= new CGameRoomInfo();		//	当前房间信息
		
		public static var isRoomMaster:Boolean		= false;		//	当前玩家是否为房主		
		public static var isGameStart:Boolean		= false;		//	是否游戏已经开始
		public static var isShowInfo:Boolean		= false;		//	是否显示提示
		
		public static const MAX_POWER:Number		= 10;	//	爆气最大值
		public static const UP_LEVEL_LINE:Number	= 10;	//	升级速度需要的行数
		public static const MAX_SPEED:Number		= 18;	//	可升级的速度上限
		public static const ADD_SCORE_DEAD:Number	= 5;	//	结算时,为仍然存活的玩家每秒追加的分值			
		
		private static var tMsg:MessageBox;
		
		public static var fDebug:Object;
		
		public static function Trace(...argc):void
		{
			if(fDebug)
			{
				if(fDebug["traceError"])
				{
					var fn:Function = fDebug["traceError"] as Function;
					fn.call(null, argc);
				}			
			}
		}
		
		//	显示一个对话框
		public static function ShowMessage(	spr:DisplayObjectContainer, 
											msg:String, 
											isSelect:Boolean = false, 
											func1:Function = null, 
											func2:Function = null):void
		{
			var tMsg:MessageBox = MessageBox.GetBox(isSelect);//new MessageBox(isSelect);
			tMsg.msg = msg;
			tMsg.x = tMsg.objHeight/3;
			tMsg.y = tMsg.objHeight/2;
			tMsg.Show();
			
			if(spr.parent)
			{
				spr.parent.addChild(tMsg);
			}
			else
			{
				spr.addChild(tMsg);
			}
			
			if(isSelect)
			{
				if(func1 == null)
				{
					throw new Error("请给出点击 OK 按钮后对应的处理事件!!");					
				}
				else
				{
					tMsg.addEventListener(MessageBox.CLICK_OK, func1);
				}
				
				if(func2 == null)
				{
					throw new Error("请给出点击 Cancel 按钮后对应的处理事件!!");
				}
				else
				{
					tMsg.addEventListener(MessageBox.CLICK_CANCEL, func2);
				}
			}
			else
			{
				if(func1 == null)
				{
					tMsg.addEventListener(MessageBox.CLICK_OK, function(e:Event):void {MessageBox(e.target).Hidden(); });
				}
				else
				{
					tMsg.addEventListener(MessageBox.CLICK_OK, func1);
				}
			}	
			
			tMsg.addEventListener(MessageBox.CLICK_CLOSE, function(e:Event):void {MessageBox(e.target).Hidden(); });
		}
		
		public function GStatic()
		{
			throw new CreateError("GStatic");
		}
	}
}